package com.he.combinationmodel;

import com.he.combinationmodel.compoent.Compoent;
import com.he.combinationmodel.composite.Composite;
import com.he.combinationmodel.leaf.Leaf;

public class Client {
    public static void main(String[] args) {
        Compoent root = new Composite("root");
        Compoent leaf1 = new Leaf("叶子1");
        Compoent leaf2 = new Leaf("叶子1");
        Compoent composite1 = new Composite("树枝1");
        Compoent composite2 = new Composite("树枝2");
        root.add(composite1);
        root.add(composite2);
        Compoent leaf3 = new Leaf("叶子3");
        Compoent leaf4 = new Leaf("叶子4");
        composite1.add(leaf3);
        composite2.add(leaf4);
        root.add(leaf1);
        root.add(leaf2);
        root.display(1);

    }
}
